<?php
/*****************************************工厂方法getResult***********************************************************************/

//抽象类  进行构造抽象的方法
abstract class Operation
{
    public $num1;
    public $num2;

    public function set($num1,$num2){
        $this->num1=$num1;
        $this->num2=$num2;
    }

    public abstract function option();

}

//继承抽象类型  实现抽象方法
class    Add extends Operation{

    public function option()
    {
        return $this->num1+$this->num2;
    }

}

class multiplication extends Operation{

    public function option(){
        return $this->num1*$this->num2;
    }
}

//抽象工厂方法
interface Option{
    public function Create();
}
class AddNum implements Option{
    public function Create()
    {
        // TODO: Implement Create() method.
        return new Add();
    }
}
class Chen implements Option{
    public function Create()
    {
        return new multiplication();
    }
}
$factory=new AddNum();
$end=$factory->Create();
$end->set(1,3);
$result=$end->option();
var_dump($result);die();
?>
